﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EzDesk.DevHelper.FeedStudio.ToEzML;
using EzDesk.DevHelper.FeedStudio.Views;
using EzDesk.DevHelper.FeedStudio.EzML;

namespace EzDesk.DevHelper.FeedStudio.Presenter
{
     public class EzMLPresenter
    {
         private IEzMLView _view;
         private IFeedView _feedView;
         private string _originalEzMLContent;
         private string _sectionName;

         public EzMLPresenter(EzMLForm view, IFeedView feedForm, string sectionName, string originalEzMLContent)
         {
             this._view = view;
             this._feedView = feedForm;
             this._originalEzMLContent = originalEzMLContent;
             this._sectionName = sectionName;
         }


         internal void ResetContent()
         {
             _view.DisplayFeedEzML(_sectionName, _originalEzMLContent);
         }


         internal void RefreshText(string ezmlLanguageContent)
         {
             EzMLBuilder builder = new EzMLBuilder(ezmlLanguageContent, _sectionName);
             string ezml = builder.Build();

             if (_sectionName.ToLower() == "title")
             {
                 _feedView.ChangeFeedTitle(ezml);
             }
             if (_sectionName.ToLower() == "body")
             {
                 _feedView.ChangeFeedBody(ezml);
             }

         }

         internal void CloseForm()
         {
             _feedView.SetEditButtonsEnabled(true);
         }
    }
}
